package handler

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"zg5/videos/api-gateway/internal/request"
	"zg5/videos/common/global"
	"zg5/videos/common/proto/users"
)

func UserInfo(c *gin.Context) {

	var req request.UserInfoReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 500,
			"msg":  err.Error(),
			"Data": nil,
		})
		return
	}
	info, err := global.UserGrpc.UserInfo(c, &users.UserInfoRequest{UserId: uint64(req.UserId)})
	if err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 500,
			"msg":  err.Error(),
			"Data": nil,
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 0,
		"msg":  "success",
		"Data": info,
	})
}
